package org.bes.WinClass;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.*;


public class FileOperation {
    Path filePath;  // 文件路径
    String operation;  // 操作类型：update, remove, move
    String version;  // 文件版本
    List<JarFileOperation> jarFileOperations;  // 如果是 JAR 文件，存储其中的类文件操作

    public FileOperation(Path filePath, String operation, String version) {
        this.filePath = filePath;
        this.operation = operation;
        this.version = version;
        this.jarFileOperations = new ArrayList<>();
    }

    // 添加 JAR 文件操作
    public void addJarFileOperation(JarFileOperation jarFileOperation) {
        this.jarFileOperations.add(jarFileOperation);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("FileOperation{")
                .append("file='").append(filePath).append('\'')
                .append(", operation='").append(operation).append('\'')
                .append(", version='").append(version).append('\'');

        if (!jarFileOperations.isEmpty()) {
            sb.append(", jarFileOperations=").append(jarFileOperations);
        }
        sb.append('}');
        return sb.toString();
    }
}